//频道配置

import React, { useState, useEffect } from 'react';
import { get_pindao_list, delete_pindao_list } from '../../utils/api';
import Tbale from '../ContentManagement/content_components/Tbale';
import Toptitle from '../../Compon/Toptitle';
import moment from 'moment';
import { Button, message } from 'antd';
import UploadFile from '../../Compon/UploadFile';
import Gooutfile from '../../Compon/file/Gooutfile.jsx';
export default function Channel() {
  const [list, setlist] = useState([]);
  const a = async () => {
    const res = await get_pindao_list();
    setlist(res.data.data);
    console.log(res.data.data);
  };
  useEffect(() => {
    a();
  }, []);
  const columns = [
    {
      title: 'ID',
      dataIndex: '_id',
      key: '_id',
    },
    {
      title: '频道名称',
      dataIndex: 'pindao_name',
      key: 'pindao_name',
    },
    {
      title: '所属页面',
      dataIndex: 'pindao_suoshuyemian',
      key: 'pindao_suoshuyemian',
    },
    {
      title: '排序值',
      dataIndex: 'pindao_paixuzhi',
      key: 'pindao_paixuzhi',
    },
    {
      title: '创建时间',
      dataIndex: 'pindao_time',
      key: 'pindao_time',
      render: (text: number | string) => {
        return moment(text).format('YYYY-MM-DD HH:mm:ss');
      },
    },
    {
      title: '操作',
      dataIndex: '_id',
      key: '_id',
      render: (text: any, record: any) => {
        return (
          <div>
            <span
              style={{ color: '#ff4d4f', cursor: 'pointer' }}
              onClick={async () => {
                message.success('删除成功');
              }}
            >
              删除
            </span>
          </div>
        );
      },
    },
  ];

  return (
    <div>
      <Toptitle title="频道管理"></Toptitle>
      <div style={{ width: '90%', margin: '0 auto' }}>
        <Tbale data={list} colums={columns} />
      </div>
      <div style={{ display: 'flex' }}>
        <UploadFile
          name={'导入'}
          // url="http://localhost:3000/CustomerService/index/uploadFile"
        ></UploadFile>

        <Gooutfile data={list}></Gooutfile>
      </div>
    </div>
  );
}
